package com.crud.project.service;

import com.crud.project.dao.IUserDao;
import com.crud.project.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {
    @Resource
    private IUserDao iUserDao;

    public List<User> findAllUser(){
        List<User> userList=iUserDao.findAll();
        return userList;
    }

    public List<User> findAllUserName(String username){
        List<User> userList=iUserDao.findAllByUserName(username);
        return userList;
    }

    public void insertUser(User user){
        iUserDao.insertUser(user);
    }

    public void deleteUserById(Long id){
        iUserDao.deleteUser(id);
    }

    public User findById(Long id){
        User user=iUserDao.findUserById(id);
        return user;
    }

    public void updateUser(User user){
        iUserDao.updateUser(user);
    }
}
